package com.yingsheng.bi.hks.service.servicedetail;

import com.yingsheng.bi.hks.bo.ServiceDetailBo;
import com.yingsheng.bi.hks.dto.servicedetail.*;
import com.yingsheng.bi.hks.mapping.ServiceDetailMgmtMappings;
import com.yingsheng.bi.hks.repository.dao.po.ServiceDetail;
import com.yingsheng.bi.hks.repository.dao.service.ServiceDetailDaoService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Slf4j
@Service
public class ServiceDetailMgmtService {

    @Autowired
    private ServiceDetailDaoService serviceDetailDaoService;

    /**
     * 收件信息新增
     * @param req
     * @return
     */
    public ServiceDetailAddRes add(ServiceDetailAddReq req) {
        ServiceDetail serviceDetail = ServiceDetailMgmtMappings.INSTANCE.addReq2po(req);
        serviceDetailDaoService.insert(serviceDetail);
        return new ServiceDetailAddRes();
    }

    public ServiceDetailModRes mod(ServiceDetailModReq req) {
        ServiceDetail serviceDetail = ServiceDetailMgmtMappings.INSTANCE.addReq2po(req);
        serviceDetailDaoService.updateById(serviceDetail);
        return new ServiceDetailModRes();
    }

    public ServiceDetailQryRes qry(ServiceDetailQryReq req) {
        List<ServiceDetail> list = serviceDetailDaoService.query(req);
        List<ServiceDetailBo> addrList = ServiceDetailMgmtMappings.INSTANCE.serviceDetailList2boList(list);
        ServiceDetailQryRes res = new ServiceDetailQryRes();
        res.setServiceDetailBoList(addrList);
        return res;
    }

    public ServiceDetailDelRes del(ServiceDetailDelReq req) {
        serviceDetailDaoService.del(req.getId());
        ServiceDetailDelRes res = new ServiceDetailDelRes();
        return res;
    }
}
